// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.Collections;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

public class ZomboidHashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable {
    static final long serialVersionUID = -5024744406713321676L;
    private transient ZomboidHashMap<E, Object> map;
    private static final Object PRESENT = new Object();

    public ZomboidHashSet() {
        this.map = new ZomboidHashMap<>();
    }

    public ZomboidHashSet(Collection<? extends E> c) {
        this.map = new ZomboidHashMap<>(Math.max((int)((float)c.size() / 0.75F) + 1, 16));
        this.addAll(c);
    }

    public ZomboidHashSet(int initialCapacity, float loadFactor) {
        this.map = new ZomboidHashMap<>(initialCapacity);
    }

    public ZomboidHashSet(int initialCapacity) {
        this.map = new ZomboidHashMap<>(initialCapacity);
    }

    public Iterator<E> iterator() {
        return this.map.keySet().iterator();
    }

    public int size() {
        return this.map.size();
    }

    public boolean isEmpty() {
        return this.map.isEmpty();
    }

    public boolean contains(Object o) {
        return this.map.containsKey(o);
    }

    public boolean add(E object) {
        return this.map.put((E)object, PRESENT) == null;
    }

    public boolean remove(Object o) {
        return this.map.remove(o) == PRESENT;
    }

    public void clear() {
        this.map.clear();
    }

    public Object clone() {
        try {
            ZomboidHashSet zomboidHashSet0 = (ZomboidHashSet)super.clone();
            zomboidHashSet0.map = (ZomboidHashMap<E, Object>)this.map.clone();
            return zomboidHashSet0;
        } catch (CloneNotSupportedException cloneNotSupportedException) {
            throw new InternalError();
        }
    }

    private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
        objectOutputStream.defaultWriteObject();
        objectOutputStream.writeInt(this.map.size());
        Iterator iterator = this.map.keySet().iterator();

        while (iterator.hasNext()) {
            objectOutputStream.writeObject(iterator.next());
        }
    }

    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
    }
}
